﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShopCusList.aspx.cs" Inherits="ShopCusList" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>单模模板</title>
    <script src="./../js/extTools.js" type="text/javascript"></script>
    <link href="./../css/ExtStyle.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery/jquery-1.8.1.min.js" type="text/javascript"></script>
    <script src="../js/jquery/jquery.iDialog.js" dialog-theme="default" type="text/javascript"></script>
    <script src="../js/config.js" type="text/javascript"></script>
    <script>
        $(function () {
            $(".btnimg").live("click", function () {
                //alert($(this).attr('src'));
                $.dialog({
                    title: '图片预览',
                    lock: true,
                    content: '<img src="' + $(this).attr('src') + '" width="418" height="387">'
                });
            });
        });
        var addRecord = function (form, grid) {
            //            if (!form.getForm().isValid()) {
            //                Ext.net.Notification.show({
            //                    iconCls: "icon-exclamation",
            //                    html: "Form is invalid",
            //                    title: "Error"
            //                });

            //                return false;
            //            }
            App.Panel3.setTitle("详细资料-新增");
            App.ActState.setValue("Add");
            App.Panel3.setCollapsed(false);
            form.getForm().reset();
            //grid.store.insert(0, form.getForm().getFieldValues());
            //            grid.getSelectionModel().selectRow(0); //选中第一行
            //            grid.getView().focusRow(0); //获取焦点

        };
        var editRecord = function (form, grid) {
            if (grid.getSelectionModel().getCount() == 0) {
                Ext.Msg.notify('温馨提示', '请选择需要编辑的行！');
                return false;
            }
            App.ActState.setValue("Edit");
            App.Panel3.setCollapsed(false);
            //grid.store.insert(0, form.getForm().getFieldValues());
            //            grid.getSelectionModel().selectRow(0); //选中第一行
            //            grid.getView().focusRow(0); //获取焦点
            App.Panel3.setTitle("详细资料-编辑");
        };
        var deleteRecord = function (form, grid) {
            if (grid.getSelectionModel().getCount() == 0) {
                Ext.Msg.notify('温馨提示', '请选择需要删除的行！');
                return false;
            }
            grid.deleteSelected();
            form.getForm().reset();
            CompanyX.BtnDelete();
        };
        var saveRecord = function (obj) {
            var fields = "";
            var vals = "";
            var str;
            obj.items.each(function (item, index, length) {
                if (item.getValue() != null) {
                    str = item.initialConfig.id;
                    fields += str.substring(3, str.length) + ",";
                    if (item.getXType() == "datefield") {
                        vals += Ext.util.Format.date(item.getValue(), 'Y-m-d') + ",";
                    } else
                        vals += item.getValue() + ",";
                }
            });
            if (obj.getForm().isValid()) {
                fields = fields.substring(0, fields.length - 1);
                vals = vals.substring(0, vals.length - 1);
                CompanyX.BtnSave(fields, vals);
            }
            //            alert(obj.getForm().getValues(true));
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Crisp" />
        <ext:Viewport ID="Viewport1" runat="server">
            <LayoutConfig>
                <ext:HBoxLayoutConfig Align="Stretch" />
            </LayoutConfig>
            <Defaults>
                <ext:Parameter Name="margin" Value="0" Mode="Value" />
            </Defaults>
            <Items>
                <ext:Panel ID="Panel1" runat="server" Flex="1" Layout="FitLayout">
                    <TopBar>
                        <ext:Toolbar ID="Toolbar1" runat="server">
                            <Items>
                                <ext:Button ID="Button5" runat="server" Text="新增" IconCls="add24" Scale="Large" IconAlign="Left"
                                    Cls="x-btn-as-arrow" RowSpan="3">
                                    <Listeners>
                                        <Click Handler="addRecord(#{Editpanel},#{MainPanel})" />
                                    </Listeners>
                                </ext:Button>
                                <ext:Button ID="Button4" runat="server" Text="修改" IconCls="edit24" Scale="Large"
                                    IconAlign="Left" Cls="x-btn-as-arrow" RowSpan="3">
                                    <Listeners>
                                        <Click Handler="editRecord(#{Editpanel},#{MainPanel})" />
                                    </Listeners>
                                </ext:Button>
                                <ext:Button ID="Button6" runat="server" Text="删除" IconCls="del24" Scale="Large" IconAlign="Left"
                                    Cls="x-btn-as-arrow" RowSpan="3">
                                    <Listeners>
                                        <Click Handler="if(!confirm('确定要删除？'))
                                            { return false; }else{deleteRecord(#{Editpanel},#{MainPanel})};" />
                                    </Listeners>
                                </ext:Button>
                                <ext:Button ID="Button10" runat="server" Text="查找" IconCls="find24" Scale="Large"
                                    IconAlign="Left" Cls="x-btn-as-arrow" RowSpan="3">
                                    <DirectEvents>
                                        <Click OnEvent="BtnFind">
                                            <EventMask ShowMask="true" Msg="加载中..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="Button7" runat="server" Text="同步数据" IconCls="check124" Scale="Large"
                                    IconAlign="Left" Cls="x-btn-as-arrow" RowSpan="3">
                                    <DirectEvents>
                                        <Click OnEvent="BtnGetShop">
                                            <EventMask ShowMask="true" Msg="加载中..." />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="Button8" runat="server" Text="关闭" IconCls="close24" Scale="Large"
                                    IconAlign="Top" Cls="x-btn-as-arrow" RowSpan="3" Visible="false" />
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Items>
                        <ext:Panel ID="Panel2" runat="server" Layout="BorderLayout">
                            <Items>
                                <ext:GridPanel runat="server" ID="MainPanel" Region="Center" Title="数据列表" Icon="ApplicationViewIcons"
                                    DeferRowRender="true">
                                    <TopBar>
                                        <ext:Toolbar runat="server">
                                            <Items>
                                                <ext:TextField runat="server" id="txtshop" EmptyText="输入编号/名称搜索" />
                                            </Items>
                                        </ext:Toolbar>
                                    </TopBar>
                                    <Store>
                                        <ext:Store ID="MainStore" runat="server" PageSize="50" OnReadData="MyData_Refresh">
                                            <Model>
                                                <ext:Model ID="Model1" runat="server">
                                                   
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                    <ColumnModel>
                                        
                                    </ColumnModel>
                                    <SelectionModel>
                                        <ext:RowSelectionModel ID="RowSelectionModel3" runat="server" />
                                    </SelectionModel>
                                    <Listeners>
                                        <CellClick Handler="#{EditPanel}.getForm().loadRecord(record);
                                        #{ActState}.setValue('Edit'); #{Panel3}.setTitle('详细资料-编辑');">
                                        </CellClick>
                                    </Listeners>
                                    <BottomBar>
                                        <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                                            <Items>
                                                <ext:Label ID="Label1" runat="server" Text="每页显示:" />
                                                <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                                <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                                    <Items>
                                                        <ext:ListItem Text="10" />
                                                        <ext:ListItem Text="20" />
                                                        <ext:ListItem Text="50" />
                                                        <ext:ListItem Text="100" />
                                                    </Items>
                                                    <SelectedItems>
                                                        <ext:ListItem Value="50" />
                                                    </SelectedItems>
                                                    <Listeners>
                                                        <Select Handler="#{MainPanel}.store.pageSize = parseInt(this.getValue(), 10); #{MainPanel}.store.reload();" />
                                                    </Listeners>
                                                </ext:ComboBox>
                                            </Items>
                                            <Plugins>
                                                <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                                            </Plugins>
                                        </ext:PagingToolbar>
                                    </BottomBar>
                                </ext:GridPanel>
                                <ext:Panel Region="East" ID="Panel3" runat="server" Split="true" Collapsible="true"
                                    Collapsed="true" Title="详细信息" Icon="ApplicationFormEdit" PaddingSummary="5px 5px 0"
                                    Width="550" ButtonAlign="Center" Layout="BorderLayout">
                                    <Items>
                                        <ext:FormPanel ID="EditPanel" runat="server" Layout="Column" Border="false" Reference="form"
                                            ButtonAlign="Center" Title="基本信息" Region="North">
                                            <Items>
                                            </Items>
                                        </ext:FormPanel>
                                        <ext:Panel runat="server" Title="上传图片" Region="South" Height="200" Layout="AnchorLayout">
                                            <Items>
                                                <ext:RadioGroup ID="RadioGroup1" runat="server" GroupName="RadioGroup1" FieldLabel="图片类型"
                                                    Cls="x-check-group-alt">
                                                    <Items>
                                                        <ext:Radio ID="Radio7" runat="server" BoxLabel="平面图" InputValue="FlatImg" />
                                                        <ext:Radio ID="Radio1" runat="server" BoxLabel="设备图1" InputValue="DeviceImg1" Checked="true" />
                                                        <ext:Radio ID="Radio2" runat="server" BoxLabel="设备图2" InputValue="DeviceImg2" />
                                                        <ext:Radio ID="Radio3" runat="server" BoxLabel="设备图3" InputValue="DeviceImg3" />
                                                        <ext:Radio ID="Radio4" runat="server" BoxLabel="设备图4" InputValue="DeviceImg4" />
                                                        <ext:Radio ID="Radio5" runat="server" BoxLabel="设备图5" InputValue="DeviceImg5" />
                                                        <ext:Radio ID="Radio6" runat="server" BoxLabel="设备图6" InputValue="DeviceImg6" />
                                                    </Items>
                                                </ext:RadioGroup>
                                                <ext:MultiUpload ID="MultiUpload1" runat="server" OnFileUpload="MultiUpload1_FileUpload"
                                                    AutoStartUpload="true" FileDropAnywhere="true" FileSizeLimit="15 MB" FileTypes="*.*"
                                                    FileTypesDescription="All Files" FileUploadLimit="100" FileQueueLimit="0">
                                                    <Button>
                                                        <ext:Button ID="Button3" runat="server" Text="上传图片" Icon="FolderImage">
                                                        </ext:Button>
                                                    </Button>
                                                    <Listeners>
                                                        <UploadStart Handler="Ext.Msg.wait('导入中，请稍等...');" />
                                                        <UploadError Fn="uploadError" />
                                                        <FileSelectionError Fn="fileSelectionError" />
                                                        <UploadComplete Handler="Ext.Msg.hide();" />
                                                    </Listeners>
                                                </ext:MultiUpload>
                                                <ext:Button ID="Button9" runat="server" Text="删除图片" Icon="Delete" OnDirectClick="BtnDeleteImg" />
                                            </Items>
                                        </ext:Panel>
                                    </Items>
                                    <Buttons>
                                        <ext:Button ID="Button1" runat="server" Text="保存修改" Icon="Disk">
                                            <Listeners>
                                                <Click Handler="
                                            r = #{EditPanel}.getForm().getRecord(); 
                                            if (r) {
                                                //#{EditPanel}.getForm().updateRecord(#{MainPanel}.getSelectionModel().getLastSelected());
                                            };
                                            saveRecord(#{EditPanel});" />
                                            </Listeners>
                                            <DirectEvents>
                                                <Click />
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:Button ID="Button2" runat="server" Text="取消" Icon="Cancel">
                                            <Listeners>
                                                <Click Handler="#{EditPanel}.getForm().reset();#{Panel3}.setCollapsed(true);" />
                                            </Listeners>
                                        </ext:Button>
                                    </Buttons>
                                </ext:Panel>
                            </Items>
                        </ext:Panel>
                    </Items>
                </ext:Panel>
                <ext:Hidden ID="ActState" runat="server" ClientIDMode="Static" Text="Edit" />
            </Items>
        </ext:Viewport>
    </div>
    </form>
</body>
</html>
